package com.bh.web.controller.extend;

import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.core.page.TableDataInfo;
import com.bh.common.enums.BusinessType;
import com.bh.common.utils.poi.ExcelUtil;
import com.bh.extend.domain.JcLedSend;
import com.bh.extend.service.IJcLedSendService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预派送单Controller
 * 
 * @author slx
 * @date 2023-08-09
 */
@RestController
@RequestMapping("/extend/ledSend")
public class JcLedSendController extends BaseController
{
    @Autowired
    private IJcLedSendService jcLedSendService;

    /**
     * 查询预派送单列表
     */
    @ApiOperation("查询预派送单列表")
    @PreAuthorize("@ss.hasPermi('extend:ledSend:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcLedSend jcLedSend)
    {
        startPage();
        List<JcLedSend> list = jcLedSendService.selectJcLedSendList(jcLedSend);
        return getDataTable(list);
    }

    /**
     * 导出预派送单列表
     */
    @PreAuthorize("@ss.hasPermi('extend:ledSend:export')")
    @Log(title = "预派送单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcLedSend jcLedSend)
    {
        List<JcLedSend> list = jcLedSendService.selectJcLedSendList(jcLedSend);
        ExcelUtil<JcLedSend> util = new ExcelUtil<JcLedSend>(JcLedSend.class);
        util.exportExcel(response, list, "预派送单数据");
    }

    /**
     * 获取预派送单详细信息
     */
    @ApiOperation("获取预派送单详细信息")
    @PreAuthorize("@ss.hasPermi('extend:ledSend:query')")
    @GetMapping("/{sendId}")
    public AjaxResult getInfo(@PathVariable("sendId") Long sendId)
    {
        return success(jcLedSendService.selectJcLedSendBySendId(sendId));
    }

    /**
     * 新增预派送单
     */
    @ApiOperation("新增预派送单")
    @PreAuthorize("@ss.hasPermi('extend:ledSend:add')")
    @Log(title = "预派送单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcLedSend jcLedSend)
    {
        return toAjax(jcLedSendService.insertJcLedSend(jcLedSend));
    }

    /**
     * 修改预派送单
     */
    @ApiOperation("修改预派送单")
    @PreAuthorize("@ss.hasPermi('extend:ledSend:edit')")
    @Log(title = "预派送单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcLedSend jcLedSend)
    {
        return toAjax(jcLedSendService.updateJcLedSend(jcLedSend));
    }

    /**
     * 删除预派送单
     */
    @ApiOperation("删除预派送单")
    @PreAuthorize("@ss.hasPermi('extend:ledSend:remove')")
    @Log(title = "预派送单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sendIds}")
    public AjaxResult remove(@PathVariable String[] sendIds)
    {
        return toAjax(jcLedSendService.deleteJcLedSendBySendIds(sendIds));
    }
}
